{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 131,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.503095700Z",
     "start_time": "2024-02-26T02:09:34.423117100Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import pickle\n",
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "csitrade=pd.read_csv('E:/baselines/ZZ500.csv')\n",
    "# csitrade.rename(columns={'Close':'close'},inplace=True)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.617507300Z",
     "start_time": "2024-02-26T02:09:34.463686500Z"
    }
   },
   "id": "5e3cd19a103a6413",
   "execution_count": 132
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "#数据一定要按股票排序\n",
    "csitrade['close_r']=csitrade['close']/csitrade['close'].shift(1)\n",
    "csitrade.reset_index(inplace=True,drop=True)\n",
    "csitrade['dt'] = csitrade['dt'].astype('datetime64[ns]')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.692780500Z",
     "start_time": "2024-02-26T02:09:34.578879400Z"
    }
   },
   "id": "417ef41b5b2fa6e5",
   "execution_count": 133
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           kdcode         dt  close   open   high    low     turnover  \\\n0       000009.SZ 2018-01-02   7.32   7.27   7.33   7.23  140497530.0   \n1       000009.SZ 2018-01-03   7.42   7.32   7.44   7.30  170636551.0   \n2       000009.SZ 2018-01-04   7.64   7.52   7.70   7.51  358089946.0   \n3       000009.SZ 2018-01-05   7.55   7.65   7.65   7.51  196259451.0   \n4       000009.SZ 2018-01-08   7.52   7.55   7.63   7.46  178511079.0   \n...           ...        ...    ...    ...    ...    ...          ...   \n169007  603883.SH 2023-12-25  29.37  29.02  29.58  28.80  101007153.0   \n169008  603883.SH 2023-12-26  29.05  29.26  29.49  28.82   66158144.0   \n169009  603883.SH 2023-12-27  30.08  28.94  30.40  28.80  206474442.0   \n169010  603883.SH 2023-12-28  28.98  30.15  30.20  28.44  264520627.0   \n169011  603883.SH 2023-12-29  29.89  28.97  30.00  28.80  204020452.0   \n\n            volume   close_r  \n0       19269993.0       NaN  \n1       23092097.0  1.013661  \n2       46992707.0  1.029650  \n3       25990264.0  0.988220  \n4       23703431.0  0.996026  \n...            ...       ...  \n169007   3457490.0  1.012061  \n169008   2272587.0  0.989105  \n169009   6939076.0  1.035456  \n169010   9053474.0  0.963431  \n169011   6878338.0  1.031401  \n\n[169012 rows x 9 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>kdcode</th>\n      <th>dt</th>\n      <th>close</th>\n      <th>open</th>\n      <th>high</th>\n      <th>low</th>\n      <th>turnover</th>\n      <th>volume</th>\n      <th>close_r</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000009.SZ</td>\n      <td>2018-01-02</td>\n      <td>7.32</td>\n      <td>7.27</td>\n      <td>7.33</td>\n      <td>7.23</td>\n      <td>140497530.0</td>\n      <td>19269993.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>000009.SZ</td>\n      <td>2018-01-03</td>\n      <td>7.42</td>\n      <td>7.32</td>\n      <td>7.44</td>\n      <td>7.30</td>\n      <td>170636551.0</td>\n      <td>23092097.0</td>\n      <td>1.013661</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>000009.SZ</td>\n      <td>2018-01-04</td>\n      <td>7.64</td>\n      <td>7.52</td>\n      <td>7.70</td>\n      <td>7.51</td>\n      <td>358089946.0</td>\n      <td>46992707.0</td>\n      <td>1.029650</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>000009.SZ</td>\n      <td>2018-01-05</td>\n      <td>7.55</td>\n      <td>7.65</td>\n      <td>7.65</td>\n      <td>7.51</td>\n      <td>196259451.0</td>\n      <td>25990264.0</td>\n      <td>0.988220</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>000009.SZ</td>\n      <td>2018-01-08</td>\n      <td>7.52</td>\n      <td>7.55</td>\n      <td>7.63</td>\n      <td>7.46</td>\n      <td>178511079.0</td>\n      <td>23703431.0</td>\n      <td>0.996026</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>169007</th>\n      <td>603883.SH</td>\n      <td>2023-12-25</td>\n      <td>29.37</td>\n      <td>29.02</td>\n      <td>29.58</td>\n      <td>28.80</td>\n      <td>101007153.0</td>\n      <td>3457490.0</td>\n      <td>1.012061</td>\n    </tr>\n    <tr>\n      <th>169008</th>\n      <td>603883.SH</td>\n      <td>2023-12-26</td>\n      <td>29.05</td>\n      <td>29.26</td>\n      <td>29.49</td>\n      <td>28.82</td>\n      <td>66158144.0</td>\n      <td>2272587.0</td>\n      <td>0.989105</td>\n    </tr>\n    <tr>\n      <th>169009</th>\n      <td>603883.SH</td>\n      <td>2023-12-27</td>\n      <td>30.08</td>\n      <td>28.94</td>\n      <td>30.40</td>\n      <td>28.80</td>\n      <td>206474442.0</td>\n      <td>6939076.0</td>\n      <td>1.035456</td>\n    </tr>\n    <tr>\n      <th>169010</th>\n      <td>603883.SH</td>\n      <td>2023-12-28</td>\n      <td>28.98</td>\n      <td>30.15</td>\n      <td>30.20</td>\n      <td>28.44</td>\n      <td>264520627.0</td>\n      <td>9053474.0</td>\n      <td>0.963431</td>\n    </tr>\n    <tr>\n      <th>169011</th>\n      <td>603883.SH</td>\n      <td>2023-12-29</td>\n      <td>29.89</td>\n      <td>28.97</td>\n      <td>30.00</td>\n      <td>28.80</td>\n      <td>204020452.0</td>\n      <td>6878338.0</td>\n      <td>1.031401</td>\n    </tr>\n  </tbody>\n</table>\n<p>169012 rows × 9 columns</p>\n</div>"
     },
     "execution_count": 134,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "csitrade"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.730434900Z",
     "start_time": "2024-02-26T02:09:34.689545900Z"
    }
   },
   "id": "a7ce26a32ed9a4e5",
   "execution_count": 134
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# a2c ddpg ppo td3 sac\n",
    "drl = 'sac'\n",
    "dtrader=pd.read_csv(f'DRL/{drl}/ZZ500.csv')\n",
    "df_return=pd.DataFrame(dtrader[drl])\n",
    "df_return.rename(columns={drl:'daily_return'}, inplace=True)\n",
    "df_return=df_return/df_return.shift(1)\n",
    "df_return.fillna(1,inplace=True)\n",
    "df_return['daily_return']=df_return['daily_return']-1"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.750696300Z",
     "start_time": "2024-02-26T02:09:34.722643400Z"
    }
   },
   "id": "f9e5d9beadd2a23c",
   "execution_count": 135
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\胡逸凡\\AppData\\Local\\Temp\\ipykernel_4184\\774818839.py:6: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  df_trade.rename(columns={'close_r' : 'daily_return'}, inplace=True)\n",
      "C:\\Users\\胡逸凡\\AppData\\Local\\Temp\\ipykernel_4184\\774818839.py:7: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  df_trade['daily_return'] = df_trade['daily_return'] - 1\n"
     ]
    }
   ],
   "source": [
    "#大盘和日收益率\n",
    "import pandas as pd\n",
    "df_trade=csitrade\n",
    "df_trade.rename(columns={'kdcode':'instrument','dt':'datetime'},inplace=True)\n",
    "df_trade=df_trade[df_trade['datetime']>'2023-01-01']\n",
    "df_trade.rename(columns={'close_r' : 'daily_return'}, inplace=True)\n",
    "df_trade['daily_return'] = df_trade['daily_return'] - 1\n",
    "index_df = df_trade.groupby('datetime')['daily_return'].mean().reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.847169400Z",
     "start_time": "2024-02-26T02:09:34.734020500Z"
    }
   },
   "id": "6fd8e5dbb14dac77",
   "execution_count": 136
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "portfolio_df_performance = df_return\n",
    "index_df_performance = index_df.set_index(['datetime'])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.848169200Z",
     "start_time": "2024-02-26T02:09:34.765395Z"
    }
   },
   "id": "3d62399ffd147a51",
   "execution_count": 137
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "     daily_return\n0        0.000000\n1       -0.000809\n2        0.000809\n3        0.000623\n4        0.004108\n..            ...\n237      0.002970\n238     -0.008770\n239      0.008303\n240      0.013748\n241      0.010391\n\n[242 rows x 1 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>daily_return</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>-0.000809</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0.000809</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0.000623</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0.004108</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>237</th>\n      <td>0.002970</td>\n    </tr>\n    <tr>\n      <th>238</th>\n      <td>-0.008770</td>\n    </tr>\n    <tr>\n      <th>239</th>\n      <td>0.008303</td>\n    </tr>\n    <tr>\n      <th>240</th>\n      <td>0.013748</td>\n    </tr>\n    <tr>\n      <th>241</th>\n      <td>0.010391</td>\n    </tr>\n  </tbody>\n</table>\n<p>242 rows × 1 columns</p>\n</div>"
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "portfolio_df_performance"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.852704300Z",
     "start_time": "2024-02-26T02:09:34.781572100Z"
    }
   },
   "id": "26b353303efd36eb",
   "execution_count": 138
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "ARR = (portfolio_df_performance['daily_return']+1).cumprod()\n",
    "ARR.to_csv(f\"DRL/daily_return/zz500/{drl}.csv\", index=None)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.852704300Z",
     "start_time": "2024-02-26T02:09:34.796277800Z"
    }
   },
   "id": "908c89c1bea4f263",
   "execution_count": 139
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "0      1.000000\n1      0.999191\n2      0.999999\n3      1.000622\n4      1.004733\n         ...   \n237    0.819849\n238    0.812659\n239    0.819406\n240    0.830671\n241    0.839303\nName: daily_return, Length: 242, dtype: float64"
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ARR"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.900645700Z",
     "start_time": "2024-02-26T02:09:34.812074900Z"
    }
   },
   "id": "8ae04edd45341918",
   "execution_count": 140
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "            daily_return\ndatetime                \n2023-01-03      0.018333\n2023-01-04     -0.000141\n2023-01-05      0.006995\n2023-01-06     -0.001129\n2023-01-09      0.006703\n...                  ...\n2023-12-25      0.001412\n2023-12-26     -0.010048\n2023-12-27      0.006425\n2023-12-28      0.012445\n2023-12-29      0.008333\n\n[242 rows x 1 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>daily_return</th>\n    </tr>\n    <tr>\n      <th>datetime</th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2023-01-03</th>\n      <td>0.018333</td>\n    </tr>\n    <tr>\n      <th>2023-01-04</th>\n      <td>-0.000141</td>\n    </tr>\n    <tr>\n      <th>2023-01-05</th>\n      <td>0.006995</td>\n    </tr>\n    <tr>\n      <th>2023-01-06</th>\n      <td>-0.001129</td>\n    </tr>\n    <tr>\n      <th>2023-01-09</th>\n      <td>0.006703</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>2023-12-25</th>\n      <td>0.001412</td>\n    </tr>\n    <tr>\n      <th>2023-12-26</th>\n      <td>-0.010048</td>\n    </tr>\n    <tr>\n      <th>2023-12-27</th>\n      <td>0.006425</td>\n    </tr>\n    <tr>\n      <th>2023-12-28</th>\n      <td>0.012445</td>\n    </tr>\n    <tr>\n      <th>2023-12-29</th>\n      <td>0.008333</td>\n    </tr>\n  </tbody>\n</table>\n<p>242 rows × 1 columns</p>\n</div>"
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index_df_performance"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.903756Z",
     "start_time": "2024-02-26T02:09:34.847169400Z"
    }
   },
   "id": "eff3c9ce821ebf76",
   "execution_count": 141
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\胡逸凡\\AppData\\Roaming\\Python\\Python310\\site-packages\\numpy\\core\\fromnumeric.py:3643: FutureWarning: The behavior of DataFrame.std with axis=None is deprecated, in a future version this will reduce over both axes and return a scalar. To retain the old behavior, pass axis=0 (or do not pass axis)\n",
      "  return std(axis=axis, dtype=dtype, out=out, ddof=ddof, **kwargs)\n",
      "C:\\Users\\胡逸凡\\AppData\\Roaming\\Python\\Python310\\site-packages\\numpy\\core\\fromnumeric.py:3643: FutureWarning: The behavior of DataFrame.std with axis=None is deprecated, in a future version this will reduce over both axes and return a scalar. To retain the old behavior, pass axis=0 (or do not pass axis)\n",
      "  return std(axis=axis, dtype=dtype, out=out, ddof=ddof, **kwargs)\n",
      "C:\\Users\\胡逸凡\\AppData\\Roaming\\Python\\Python310\\site-packages\\numpy\\core\\fromnumeric.py:3643: FutureWarning: The behavior of DataFrame.std with axis=None is deprecated, in a future version this will reduce over both axes and return a scalar. To retain the old behavior, pass axis=0 (or do not pass axis)\n",
      "  return std(axis=axis, dtype=dtype, out=out, ddof=ddof, **kwargs)\n"
     ]
    }
   ],
   "source": [
    "alpha_df_performance = pd.DataFrame()\n",
    "alpha_df_performance['portfolio_daily_return'] = portfolio_df_performance['daily_return']\n",
    "alpha_df_performance['index_daily_return'] = index_df_performance['daily_return']\n",
    "alpha_df_performance['alpha_daily_return'] = alpha_df_performance['portfolio_daily_return'] - \\\n",
    "                                                alpha_df_performance['index_daily_return']\n",
    "alpha_df_performance['portfolio_net_value'] = (alpha_df_performance['portfolio_daily_return'] + 1).cumprod()\n",
    "alpha_df_performance['index_net_value'] = (alpha_df_performance['index_daily_return'] + 1).cumprod()\n",
    "alpha_df_performance['alpha_net_value'] = (alpha_df_performance['alpha_daily_return'] + 1).cumprod()\n",
    "\n",
    "net_value_columns = ['portfolio_net_value', 'index_net_value', 'alpha_net_value']\n",
    "\n",
    "alpha_statistics_df = pd.DataFrame(index=alpha_df_performance[net_value_columns].columns,\n",
    "                                    columns=[\"年化收益\", \"年化波动率\", \"最大回撤率\", \"夏普率\", \"Calmar\", \"IR\"])\n",
    "\n",
    "# alpha_df_performance.set_index(\"dt\", inplace=True)\n",
    "alpha_df_performance.index = pd.to_datetime(alpha_df_performance.index)\n",
    "\n",
    "alpha_statistics_df.loc[:, \"年化收益\"] = np.mean(\n",
    "    (alpha_df_performance[net_value_columns].tail(1)) ** (252 / len(alpha_df_performance)) - 1)\n",
    "alpha_statistics_df.loc[:, \"年化波动率\"] = np.std(\n",
    "    alpha_df_performance[net_value_columns] / alpha_df_performance[net_value_columns].shift(1) - 1) * np.sqrt(\n",
    "    252)\n",
    "alpha_statistics_df.loc[:, \"累积收益\"] = np.mean(alpha_df_performance[net_value_columns].tail(1) - 1)\n",
    "alpha_statistics_df.loc[:, \"累积波动率\"] = np.std(\n",
    "    alpha_df_performance[net_value_columns] / alpha_df_performance[net_value_columns].shift(1) - 1)\n",
    "alpha_statistics_df.loc[:, \"最大回撤率\"] = np.min(\n",
    "    (alpha_df_performance[net_value_columns] - alpha_df_performance[net_value_columns].cummax()) /\n",
    "    alpha_df_performance[net_value_columns].cummax())\n",
    "alpha_statistics_df.loc[:, \"夏普率\"] = alpha_statistics_df[\"年化收益\"] / alpha_statistics_df[\"年化波动率\"]\n",
    "alpha_statistics_df.loc[:, \"Calmar\"] = alpha_statistics_df[\"年化收益\"] / abs(alpha_statistics_df[\"最大回撤率\"])\n",
    "alpha_statistics_df.loc[:, \"IR\"] = np.mean(\n",
    "    alpha_df_performance[net_value_columns] / alpha_df_performance[net_value_columns].shift(1) - 1) * np.sqrt(\n",
    "    252) / np.std(alpha_df_performance[net_value_columns] / alpha_df_performance[net_value_columns].shift(1) - 1)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.966615200Z",
     "start_time": "2024-02-26T02:09:34.863465400Z"
    }
   },
   "id": "4693f7e9be0e81e7",
   "execution_count": 142
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "                         年化收益     年化波动率     最大回撤率       夏普率    Calmar      IR  \\\nportfolio_net_value -0.166751  0.081048 -0.206625 -2.057444 -0.807022 -2.2187   \nindex_net_value     -0.166751       NaN -0.206625       NaN -0.807022     NaN   \nalpha_net_value     -0.166751       NaN -0.206625       NaN -0.807022     NaN   \n\n                         累积收益     累积波动率  \nportfolio_net_value -0.160697  0.005106  \nindex_net_value     -0.160697       NaN  \nalpha_net_value     -0.160697       NaN  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>年化收益</th>\n      <th>年化波动率</th>\n      <th>最大回撤率</th>\n      <th>夏普率</th>\n      <th>Calmar</th>\n      <th>IR</th>\n      <th>累积收益</th>\n      <th>累积波动率</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>portfolio_net_value</th>\n      <td>-0.166751</td>\n      <td>0.081048</td>\n      <td>-0.206625</td>\n      <td>-2.057444</td>\n      <td>-0.807022</td>\n      <td>-2.2187</td>\n      <td>-0.160697</td>\n      <td>0.005106</td>\n    </tr>\n    <tr>\n      <th>index_net_value</th>\n      <td>-0.166751</td>\n      <td>NaN</td>\n      <td>-0.206625</td>\n      <td>NaN</td>\n      <td>-0.807022</td>\n      <td>NaN</td>\n      <td>-0.160697</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>alpha_net_value</th>\n      <td>-0.166751</td>\n      <td>NaN</td>\n      <td>-0.206625</td>\n      <td>NaN</td>\n      <td>-0.807022</td>\n      <td>NaN</td>\n      <td>-0.160697</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alpha_statistics_df"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-26T02:09:34.998065Z",
     "start_time": "2024-02-26T02:09:34.915371300Z"
    }
   },
   "id": "26604cd8be5ae6",
   "execution_count": 143
  },
  {
   "cell_type": "markdown",
   "source": [
    "ASR = ARR / AVol;   CR = ARR / abs(MDD)\n",
    "              ARR    AVol    MDD    ASR     CR    IR\n",
    "nas100 a2c   0.109  0.134  -0.114  0.816  0.957  0.844\n",
    "       ddpg  0.130  0.156  -0.131  0.832  0.994  0.863\n",
    "       ppo   0.148  0.118  -0.104  1.259  1.424  1.237\n",
    "       td3   0.181  0.155  -0.160  1.169  1.130  1.156\n",
    "       sac   0.162  0.139  -0.107  1.165  1.518  1.154\n",
    "      \n",
    "sp500  a2c   0.160  0.126  -0.084  1.267  1.907  1.244\n",
    "       ddpg  0.111  0.129  -0.091  0.864  1.223  0.887\n",
    "       ppo   0.020  0.089  -0.067  0.220  0.291  0.263\n",
    "       td3   0.024  0.113  -0.105  0.209  0.225  0.264\n",
    "       sac   0.140  0.111  -0.069  1.263  2.011  1.242\n",
    "      \n",
    "zz500  a2c  -0.172  0.084  -0.208 -2.043 -0.826 -2.207\n",
    "       ddpg -0.128  0.082  -0.170 -1.563 -0.756 -1.639\n",
    "       ppo  -0.032  0.015  -0.040 -2.041 -0.787 -2.075\n",
    "       td3  -0.123  0.135  -0.248 -0.912 -0.496 -0.909\n",
    "       sac  -0.167  0.081  -0.207 -2.057 -0.807 -2.219\n",
    "      \n",
    "hs300  a2c  -0.207  0.092  -0.259 -2.255 -0.803 -2.490\n",
    "       ddpg -0.137  0.138  -0.240 -0.992 -0.568 -1.002\n",
    "       ppo  -0.096  0.045  -0.120 -2.138 -0.800 -2.234\n",
    "       td3  -0.154  0.137  -0.252 -1.122 -0.610 -1.155\n",
    "       sac  -0.140  0.090  -0.207 -1.554 -0.676 -1.635\n",
    "       "
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "fd42e032351f3588"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
